package com.legsem.jhosync.util;

/**
 * Tokens are used to uniquely identify a response sent to a client so that the
 * client can later acknowledge that particular reply.
 */
public class TokenUtil {

    /** Utility class. */
    private TokenUtil() {

    }

    /**
     * For protocol compatibility, this generates a 14 digit token. It is not
     * guaranteed to be unique across JVMs but this token is only used in
     * conjunction with a client ID. It is very unlikely that the same client ID
     * will be issuing 2 requests within the same millisecond.
     * 
     * @return a token
     */
    public static String newToken() {
        return String.format("%d", System.nanoTime());

    }

}
